package co.com.inventarios.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

public class Valida_Numero implements Validator{

    public void validate(FacesContext facesContext,
            UIComponent uIComponent, Object value) throws ValidatorException {

        //Get the component's contents and cast it to a String
	    String enteredEmail = (String)value;

        //Set the email pattern string
        Pattern p = Pattern.compile("[0-9]*");

        //Match the given string with the pattern
        Matcher m = p.matcher(enteredEmail);

        //Check whether match is found
        boolean matchFound = m.matches();

        if (!matchFound) {
            FacesMessage message = new FacesMessage();
           // message.setDetail("Solo Se Permite Valores Numericos");
            message.setSummary("Solo Se Permite Valores Numericos");
            message.setSeverity(FacesMessage.SEVERITY_ERROR);
            throw new ValidatorException(message);
        }
                 
        
    }
	
	
}
